const Router = require('koa-router')
const { create, list, detail, update, remove, updateLabel, fileInfo } = require('../controller/moment.controller')
const { verifyAuth, verifyPermission } = require('../milldleware/auth.middleware')
const { verifyLabelExists } = require('../milldleware/label.middleware')

const momentRouter = new Router({ prefix: '/moment' })

// 创建动态
momentRouter.post('/', verifyAuth, create)
// 获取所有动态
momentRouter.get('/', list)
// 获取动态详情
momentRouter.get('/:momentId', detail);
// 更新动态
momentRouter.patch('/:momentId', verifyAuth, verifyPermission, update)
// 删除动态
momentRouter.delete('/:momentId', verifyAuth, verifyPermission, remove)
// 修改或增加动态标签
momentRouter.post('/:momentId/labels', verifyAuth, verifyPermission, verifyLabelExists, updateLabel)
// 获取动态图片
momentRouter.get('/picture/:filename', fileInfo);


module.exports = momentRouter 
